function initUse(){
    var demo1=document.getElementById('web-use');
    var myChart1=echarts.init(demo1);
    var option = {
        legend: {
            show:true,
            x: 'center', // 'center' | 'left' | {number},
            y: 'bottom', // 'center' | 'bottom' | {number}
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid: {
            top:10,
            left: '3%',
            right: '4%',
            bottom: '30',
            containLabel: true
        },
        dataset: {
            source: [
                ['product', 'user_pick_up', 'field-pick_up', 'user_return','field_return'],
                ['09-11', 5, 3, 1,1],
                ['09-12', 8,6,2,1],
                ['09-13', 2,3,3,4],
                ['09-14', 10,2,8,0],
                ['09-15',6,1,6,1]
            ]
        },
        xAxis: {type: 'category'},
        yAxis: {},
        // Declare several bar series, each will be mapped
        // to a column of dataset.source by default.
        series: [
            {
                barWidth: '10%',
                type: 'bar'
            },
            {
                barWidth: '10%',
                type: 'bar'
            },
            {
                barWidth: '10%',
                type: 'bar'
            },
            {
                barWidth: '10%',
                type: 'bar'
            }
        ]
    };
    
    myChart1.setOption(option);
    return myChart1;
}
function initTurnover(){
    var dom2=document.getElementById('web-turnover');
    var myChart2=echarts.init(dom2);
    var option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid: {
            top:10,
            left: '3%',
            right: '4%',
            bottom: '30',
            containLabel: true
        },
        xAxis: [
            {
                "axisLabel":{     //加上这个强制显示
                    interval: 0
                  },
                type: 'category',
                data: ['09-11', '09-12', '09-13', '09-14', '09-15'],
                axisTick: {
                    alignWithLabel: true
                }
            }
        ],
        yAxis: [
            {
                type: 'value'
            }
        ],
        series: [
            {
                name: 'turnover_rate',
                type: 'bar',
                barWidth: '40%',
                data: [120,80,200,138,20]
            }
        ]
    };
    myChart2.setOption(option);
    return myChart2;
}




function resizeAllCharts(){
    //resize方式2
    // var compareChart = echarts.getInstanceByDom(document.getElementById("time-usingcar"));
    // compareChart.resize();

    var allChartsDom = document.getElementsByClassName("speed-chart");//class
    for (var i = 0; i < allChartsDom.length; i++) {
        var chatsDom = allChartsDom[i];
        var compareChart = echarts.getInstanceByDom(chatsDom);
        if(compareChart){
            compareChart.resize();
        }
    }

   
    // allCharts.forEach(chats => {
    //     chats.resize();
    // });
}
window.onload = function(){
    initUse();
    initTurnover();
    
};
window.onresize = function(){
    resizeAllCharts();
};